import { baseRequestClient, requestClient } from '#/api/request';

export namespace AuthApi {
  /** 登录接口参数 */
  export interface LoginParams {
    password?: string;
    username?: string;
  }

  /** 登录接口返回值 */
  export interface LoginResult {
    // accessToken: string;
    userInfo: any;
  }

  /** 获取用户基础信息接口返回值 */
  export interface GetUserBaseResult {
    // accessToken: string;
    adminInfo: any;
    menus: any;
    siteConfig:any
  }

  export interface RefreshTokenResult {
    data: string;
    status: number;
  }
}

/**
 * 登录
 */
export async function loginApi(data: AuthApi.LoginParams) {
  return requestClient.post<AuthApi.LoginResult>('/admin/index/login', data,{responseReturn:"raw"});
}

/**
 * 刷新accessToken
 */
export async function refreshTokenApi() {
  return baseRequestClient.post<AuthApi.RefreshTokenResult>('/auth/refresh', {
    withCredentials: true,
  });
}

/**
 * 退出登录
 */
export async function logoutApi() {
  return baseRequestClient.post('/admin/index/logout', {
    withCredentials: true,
  });
}

/**
 * 获取用户权限码
 */
export async function getAccessCodesApi() {
  return requestClient.get<string[]>('/auth/codes');
}

/**
 * 获取用户基础信息
 */
export async function getUserBaseApi() {
  return requestClient.get<AuthApi.GetUserBaseResult>('/admin/index/index_new');
}



/**
 上传图片后回调
 */
export async function QiniuCallback(params:any) {
   return requestClient.post('/admin/Qiniu/callback',params);
}
